# Maintainer: Johannes Schindelin <johannes.schindelin@gmx.de>

_realname=msmtp
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.8.23
pkgrel=1
pkgdesc="An SMTP client (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('spdx:GPL-3.0-or-later')
url="https://marlam.de/msmtp/"
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-gsasl"
         "${MINGW_PACKAGE_PREFIX}-libsecret"
         "${MINGW_PACKAGE_PREFIX}-libidn2"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread")
source=(https://marlam.de/msmtp/releases/${_realname}-${pkgver}.tar.xz{,.sig})
sha256sums=('cf04c16b099b3d414db4b5b93fc5ed9d46aad564c81a352aa107a33964c356b8'
            'SKIP')
validpgpkeys=('2F61B4828BBA779AECB3F32703A2A4AB1E32FD34') # Martin Lambers <marlam@marlam.de>

prepare () {
  cd ${srcdir}/${_realname}-${pkgver}

}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  LDFLAGS+=" -lpthread" \
  ../${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  sed -i 's/-R\/mingw..\/lib//' src/Makefile
  touch ${srcdir}/${_realname}-${pkgver}/src/*.c
  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
  install -Dm0644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
